import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
/* Layout */
import Layout from '@/layout';

export const constantRoutes = [

  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: '/home',
      component: () => import('@/views/home/index'),
      meta: {
        title: "首页"
      },
    }, ]
  },


  {
    path: '/admin',
    name: "权限管理",
    component: Layout,
    meta: {
      title: '权限管理',
    },
    children: [{
        path: 'adminDefault',
        name: '管理员管理',
        component: () => import('@/views/adminDefault/index'),
        meta: {
          title: '管理员管理',
        }
      },
      {
        path: 'jurisdiction',
        name: '角色管理',
        component: () => import('@/views/jurisdiction/index'),
        meta: {
          title: '角色管理',
        }
      },
      {
        path: '/admin/jurisdiction/ejurisdiction',
        name: '添加编辑角色',
        component: () => import('@/views/ejurisdiction/index'),
      },
    ]
  },
  {
    path: '/medical',
    name: "医疗信息",
    component: Layout,
    meta: {
      title: '医疗信息',
    },
    children: [{
        path: 'section',
        name: '科室信息',
        component: () => import('@/views/section/index'),
        meta: {
          title: '科室信息',
        }
      },
      {
        path: 'specialist',
        name: '专家信息',
        component: () => import('@/views/specialist/index'),
        meta: {
          title: '专家信息',
        }
      },
      {
        path: 'scheduling',
        name: '排班信息',
        component: () => import('@/views/scheduling/index'),
        meta: {
          title: '排班信息',
        }
      },
      {
        path: 'source',
        name: '号源信息',
        component: () => import('@/views/source/index'),
        meta: {
          title: '号源信息',
        }
      },
      {
        path: '/medical/scheduling/detail',
        name: '排班信息详情',
        component: () => import('@/views/schedulingDetail/index'),
      },
      {
        path: '/medical/source/detail',
        name: '号源信息详情',
        component: () => import('@/views/sourceDetail/index'),
      },
    ]
  },
  {
    path: '/clinc',
    name: "门诊预约",
    component: Layout,
    meta: {
      title: '门诊预约',
    },
    children: [{
        path: 'confirming',
        name: '待确认预约',
        component: () => import('@/views/confirming/index'),
        meta: {
          title: '待确认预约',
        }
      },
      {
        path: 'cancel',
        name: '取消预约',
        component: () => import('@/views/cancel/index'),
        meta: {
          title: '取消预约',
        }
      },
      {
        path: 'affirm',
        name: '确认预约',
        component: () => import('@/views/affirm/index'),
        meta: {
          title: '确认预约',
        }
      },
     
    ]
  },
  {
    path: '/lvtong',
    name: '绿通预约',
    component: Layout,
    meta: {
      title: '绿通预约',
    },
    children: [{
        path: 'active',
        name: '绿通服务',
        component: () => import('@/views/active/index'),
        meta: {
          title: '绿通服务',
        }
      },
      {
        path: 'apply',
        name: '预约申请',
        component: () => import('@/views/apply/index'),
        meta: {
          title: '预约申请',
        }
      },
      {
        path: 'agrees',
        name: '预约确认',
        component: () => import('@/views/agrees/index'),
        meta: {
          title: '预约确认',
        }
      },
      {
        path: 'finish',
        name: '就诊完毕',
        component: () => import('@/views/finish/index'),
        meta: {
          title: '就诊完毕',
        }
      },
      {
        path: '/lvtong/finish/detail',
        name: '就诊详情',
        component: () => import('@/views/finishDetail/index'),
      },
    ]
  },
  {
    path: '/physical',
    name: '体检预约',
    component: Layout,
    meta: {
      title: '体检预约',
    },
    children: [{
        path: 'list',
        name: '体检订单',
        component: () => import('@/views/list/index'),
        meta: {
          title: '体检订单',
        }
      },
      {
        path: 'over',
        name: '完成订单',
        component: () => import('@/views/over/index'),
        meta: {
          title: '完成订单',
        }
      },
      {
        path: '/physical/over/detail',
        name: '体检订单详情',
        component: () => import('@/views/overDetail/index'),
      },
    ]
  },
  {
    path: '/hairdressing',
    name: '美容服务',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '美容服务',
    },
    children: [{
      path: 'listSever',
      name: '管理订单',
      component: () => import('@/views/listSever/index'),
      meta: {
        title: '管理订单',
      }
    }, ]
  },
  {
    path: '/nurse',
    name: '上门护理',
    component: Layout,
    alwaysShow: true,
    meta: {
      title: '上门护理',
    },
    children: [{
        path: 'listAll',
        name: '订单管理',
        component: () => import('@/views/listAll/index'),
        meta: {
          title: '订单管理',
        }
      },
      {
        path: 'close',
        name: '取消订单',
        component: () => import('@/views/close/index'),
        meta: {
          title: '取消订单',
        }
      },
      {
        path: 'perform',
        name: '服务完成',
        component: () => import('@/views/perform/index'),
        meta: {
          title: '服务完成',
        }
      },
    ]
  },
  {
    path: '/operation',
    name: "Operation",
    hidden: true,
    component: Layout,
    children: [{
        path: '/operation/app',
        name: 'App下载',
        component: () => import('@/views/appDownload/index')
      },
      {
        path: '/operation/use',
        name: '使用说明',
        component: () => import('@/views/use/index')
      },
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]
const createRouter = () => new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
